//
//  SearchNoResultView.m
//  JiaoX
//
//  Created by yinqy on 15/2/10.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "SearchNoResultView.h"

#define TITLE_FONT_SIZE [DimensUtils getScaleX:15]

@implementation SearchNoResultView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        UILabel *label = [[UILabel alloc]init];
        [label setFont:[UIFont systemFontOfSize:TITLE_FONT_SIZE]];
        [label setTextAlignment:NSTextAlignmentCenter];
        [label setNumberOfLines:0];
        [label setTextColor:JXColor(77, 77, 77)];
        NSString *string = @"抱歉，没有找到相关商品\r\n请改变关键字重新尝试搜索";
        [label setText:string];
        CGSize labelSize = [string sizeWithFont:label.font constrainedToSize:CGSizeMake(MAXFLOAT, MAXFLOAT)];
        [label setSize:labelSize];
        
        UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ic_search_noresult"]];
        imageView.size = imageView.image.size;
        [self addSubview:imageView];
        [imageView setX:(labelSize.width-imageView.width)/2];
        [imageView setY:0];
        
        [label setX:0];
        [label setY:CGRectGetMaxY(imageView.frame)+JXPublicInset];
        
        [self addSubview:label];
        [self addSubview:imageView];
        [self setSize:CGSizeMake(label.width, CGRectGetMaxY(label.frame))];
    }
    return self;
}

@end
